Skip to content

<fix>[ha]: ZSTAC-83890 add pre-fence peer fallback#4135

Open
zstack-robot-1 wants to merge 1 commit into
5.5.22from
sync/yingzhe.hu/fix/ZSTAC-83890-pre-fence-tag-5.5.22@@2
Open

<fix>[ha]: ZSTAC-83890 add pre-fence peer fallback#4135
zstack-robot-1 wants to merge 1 commit into
5.5.22from
sync/yingzhe.hu/fix/ZSTAC-83890-pre-fence-tag-5.5.22@@2

Conversation

@zstack-robot-1
Copy link
Copy Markdown
Collaborator

Root Cause

Some HA checker paths can trigger HA without an accessiblePeerHostUuid. When this happens, core HA previously skipped creating haPreFencePending, so the KVM pre-fence extension had no chance to kill the old qemu process before starting the VM elsewhere.

Solution

  • Keep creating haPreFencePending when suspectHostUuid is available even if accessiblePeerHostUuid is missing.
  • Store accessiblePeerHostUuid as none as a deferred marker. The premium KVM pre-fence extension resolves it to the selected destination host after scheduling.

Testing

  • git diff --check

Related

  • Premium MR: pending recreation with @@2 source branch

Resolves: ZSTAC-83890

sync from gitlab !10039

Allow HA pre-fence pending tags to record accessiblePeerHostUuid as none when the checker cannot provide a peer. The late KVM pre-fence extension resolves that marker after host allocation.

Resolves: ZSTAC-83890

Change-Id: I36426b3386f1080ddeae8396ea9c4f7a81e25711
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Review Change Stack

总览

该PR在 HA 高可用性功能中,添加了一个系统标签常量,并调整了预栅栏待创建标签的创建逻辑,使其在对端主机UUID缺失时可以使用默认值继续创建标签而非跳过。

变更

HA 预栅栏标签改进

层级 / 文件 摘要
系统标签常量定义
compute/src/main/java/org/zstack/compute/vm/VmSystemTags.java
新增公开常量 HA_PRE_FENCE_ACCESSIBLE_PEER_HOST_UUID_NONE = "none",标识对端主机UUID的无值状态。
预栅栏标签创建逻辑调整
compute/src/main/java/org/zstack/compute/vm/VmInstanceBase.java
createPreFencePendingTag() 中调整条件判断:当 peerHostUuid 为空时,改为赋值默认常量后继续创建标签,而非整体跳过。

可能相关的 PR

  • MatheMatrix/zstack#4027:同样修改 VmInstanceBase.createPreFencePendingTag()VmSystemTags 中的 HA 预栅栏相关常量,代码路径直接重叠。

预估审查工作量

🎯 1 (Trivial) | ⏱️ ~5 分钟

诗句

🐰 ✨

空的对端UUID不再难,

常量"none"来救援,

标签继续创建好,

HA高可用更完善!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Pull request title follows the required '[scope]: ' format and is 50 characters, within the 72-character limit.
Description check ✅ Passed Pull request description clearly explains the root cause, solution, and related changes to the HA pre-fence tagging logic.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sync/yingzhe.hu/fix/ZSTAC-83890-pre-fence-tag-5.5.22@@2

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.42.3)
compute/src/main/java/org/zstack/compute/vm/VmInstanceBase.java

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
compute/src/main/java/org/zstack/compute/vm/VmSystemTags.java (1)

324-324: ⚡ Quick win

将哨兵常量改为不可变(Line 324)

该值被设计为跨流程约定的标记值,建议声明为 public static final,避免被误改导致预栅栏匹配逻辑异常。

建议修改
-    public static String HA_PRE_FENCE_ACCESSIBLE_PEER_HOST_UUID_NONE = "none";
+    public static final String HA_PRE_FENCE_ACCESSIBLE_PEER_HOST_UUID_NONE = "none";

As per coding guidelines “常量命名:全部大写,使用下划线分隔单词”,该命名语义对应常量,建议保持不可变。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@compute/src/main/java/org/zstack/compute/vm/VmSystemTags.java` at line 324,
The field HA_PRE_FENCE_ACCESSIBLE_PEER_HOST_UUID_NONE in class VmSystemTags
should be made an immutable constant to prevent accidental modification; change
its declaration to be public static final and keep the String value "none"
(i.e., make HA_PRE_FENCE_ACCESSIBLE_PEER_HOST_UUID_NONE a public static final
String) so the pre-fence matching logic uses an immutable, conventional
constant.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@compute/src/main/java/org/zstack/compute/vm/VmSystemTags.java`:
- Line 324: The field HA_PRE_FENCE_ACCESSIBLE_PEER_HOST_UUID_NONE in class
VmSystemTags should be made an immutable constant to prevent accidental
modification; change its declaration to be public static final and keep the
String value "none" (i.e., make HA_PRE_FENCE_ACCESSIBLE_PEER_HOST_UUID_NONE a
public static final String) so the pre-fence matching logic uses an immutable,
conventional constant.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)

Review profile: CHILL

Plan: Pro

Run ID: 87eeb2ee-3f82-4846-ab1f-f9ec008b0dbd

📥 Commits

Reviewing files that changed from the base of the PR and between 113a77a and 32e1826.

📒 Files selected for processing (2)
  • compute/src/main/java/org/zstack/compute/vm/VmInstanceBase.java
  • compute/src/main/java/org/zstack/compute/vm/VmSystemTags.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants